package com.open.exam.lock;

/**
 * @Description 获取锁管理类
 * @author 奶茶
 * Created by on 2019/2/20 9:40.
 */
public interface DistributedLocker {

    /**
     *  获取锁
     * @param lockName 锁名称
     * @param worker 获取锁后的处理类
     * @param <T>
     * @return  具体返回的业务数据
     * @throws UnableToAquireLockException
     */
    <T> T lock(String lockName, int leaseTime, int waitTime, AcquiredLockWorker<T> worker) throws UnableToAquireLockException, InterruptedException;

    <T> T lock(String lockName, AcquiredLockWorker<T> worker, int lockTime, int waitTime) throws UnableToAquireLockException, InterruptedException;

}
